<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <link rel="shortcut icon" href="#" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>demo模块</title>
  </head>
  <body>
    <div id="app"></div>
    <script>
      document.title = '\u200E';
      try {
        // 定义主题映射表
        var themeObj = {
          0: { className: 'light', attribute: 'light' },
          1: { className: 'dark', attribute: 'dark' },
          2: { className: 'private-light', attribute: 'private-light' },
          3: { className: 'private-dark', attribute: 'private-dark' },
        };

        function getQueryParam(name) {
          var search = window.location.search.substring(1);
          var params = search.split('&');
          for (var i = 0; i < params.length; i++) {
            var pair = params[i].split('=');
            if (decodeURIComponent(pair[0]) === name) {
              return decodeURIComponent(pair[1] || '');
            }
          }
          return null;
        }

        // 获取 style 参数并应用主题
        var styleParam = parseInt(getQueryParam('style'), 10);
        if (isNaN(styleParam) || !themeObj.hasOwnProperty(styleParam)) {
          styleParam = 0;
        }
        document.documentElement.setAttribute('theme', themeObj[styleParam].attribute);
      } catch (error) {
        console.error('主题标识设置异常', error);
      }
    </script>
    <script type="module" src="./main.js"></script>
  </body>
</html>
